﻿// =================================================================== 
// 数据实体层(GDIT.Model)实体映射
//====================================================================
// 文件：Mtb_DetailMenus.cs
// 项目名称：学院网站
// 创建时间：2012-08-08
// 负责人：ChenZhiGang
// 引用DevExpress.Xpo程序集
// 程序集介绍：详细菜单实体类(可理解为二级菜单)
// ===================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;

namespace GDIT.Model
{
    public class Mtb_DetailMenus : PersistentClass
    {
        public Mtb_DetailMenus()
        : base()
    {
        this.Modified = false;
    }

        public Mtb_DetailMenus(Session theSession)
        : base(theSession)
    {
        this.Modified = false;
    }

    private string _menuName = string.Empty;
    /// <summary>
    /// 详细菜单名称
    /// </summary>
    [DbType("varchar(50)")]
    public string MenuName
    {
        get { return _menuName; }
        set
        {
            if (_menuName != value)
            {
                _menuName = value;
                if (!IsLoading) { this.Modified = true; }
            }
        }
    }
   
    /// <summary>
    /// 所属导航栏菜单
    /// </summary>
    [Association("MainDetails")]
    public Mtb_MainMenus Main;

    private string _linkAddress = string.Empty;
    /// <summary>
    /// 详细菜单链接地址
    /// </summary>
    [DbType("varchar(256)")]
    public string LinkAddress
    {
        get { return _linkAddress; }
        set
        {
            if (_linkAddress != value)
            {
                _linkAddress = value;
                if (!IsLoading) { this.Modified = true; }
            }
        }
    }

    private int _sn;
    /// <summary>
    /// 顺序号
    /// </summary>
    [DbType("int")]
    public int Sn
    {
        get { return _sn; }
        set
        {
            if (_sn != value)
            {
                _sn = value;
                if (!IsLoading) { this.Modified = true; }
            }
        }
    }

    /// <summary>
    /// 防止编辑后马上保存
    /// </summary>
    protected override void EndEdit()
    {
        return;
    }

    /// <summary>
    /// 检验数据
    /// </summary>
    /// <returns></returns>
    public override string GetDataError()
    {
        if (this._linkAddress.Trim().Length == 0) { return string.Format("菜单链接不能为空"); }
        if (this._menuName.Trim().Length == 0) { return string.Format("菜单名称不能为空"); }
        return "";
    }
    }
}
